/*
 * @(#)Download.java		       Project:Tools
 * Date:2012-3-16
 *
 * Copyright (c) 2011 CFuture09, Institute of Software, 
 * Guangdong Ocean University, Zhanjiang, GuangDong, China.
 * All rights reserved.
 */
package com.sinaapp.msdxblog.tools.download;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author Geek_Soledad (66704238@51uc.com)
 */
public class Download {
	private static String downloadMyUrl() {
		URL url;
		try {
			url = new URL(
					"http://msdxandroid-dtdgdr.stor.sinaapp.com/dtdgdr.txt");
//					"http://www.youdao.com/smartresult-xml/search.s?type=id&q=111");
			HttpURLConnection urlConn = (HttpURLConnection) url
					.openConnection();
			InputStream in = urlConn.getInputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			StringBuffer buffer = new StringBuffer();
			String tmp = null;;
			while ((tmp = br.readLine())!=null) {
				buffer.append(tmp);
			}
			String string = buffer.toString();
			in.close();
			return string;
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return "";
	}
	
	public static void main(String[] args) {
		System.out.println(downloadMyUrl());
	}
}
